cc.Class({
	extends: cc.Component,

	properties: {},

	// onLoad () {},

	start() {
		this.judgePlayerNum();
		let that = this;
		cc.vv.ServerCallBack.startGame = function (data) {
			that.node.gbn("startBtn").active = false;
            cc.vv.playerColor = data;
		};
	},

	update(dt) {},

	// 判断人数是否有两人
	judgePlayerNum() {
		if (cc.vv.playerNum >= 2) {
			this.node.gbn("startBtn").active = true;
			this.node.gbn("hint").active = false;
			// cc.log(cc.vv.playerNum)
		} else {
			this.node.gbn("hint").active = true;
		}
	},

	// 开始
	onBtnState() {
		// this.node.gbn("startBtn").active = false;
		console.log(cc.vv.RoomID);
		let data = {
			type: cc.vv.communicateEvent.STARTGAME,
			data: { roomID: cc.vv.RoomID },
		};
		cc.vv.CMM.request_startGame(data, (err, info) => {
			if (err) {
				console.log(err);
			} else {
				console.log(info);
			}
		});
	},
});
